import request from '@/request/index.js'
import {C2B} from '@/utils/wordtransfer.js'

// 查询搜索并分页
export const findPages = (data) => {
   return request.post("/sysroles/page",data)
}

// 保存和更新
export const saveUpdate = (data) => {
   return request.post("/sysroles/saveupdate",data)    
}

// id查询明细
export const getById = (id) => {
   return request.post(`/sysroles/get/${id}`,{})    
}

// id删除
export const delById = (id) => {
   return request.post(`/sysroles/del/${id}`,{})    
}

// 修改状态
export const updateStatus = (id,field,value) => {
   field = C2B(field)
   return request.post(`/sysroles/status/${id}/${field}/${value}`,{})    
}

// 查询用户角色授权角色列表
export const findUserRoles = (userId) => {
   return request.post(`/sys/user/roles?userId=${userId}`,{})
}

// 保存用户角色授权
export const saveUserRoles = ({userId,roleIds}) => {
   return request.post(`/sys/user/roles/save?userId=${userId}&roleIds=${encodeURIComponent(roleIds)}`,{})
}

// 查询角色接口
export const findSysRoles = () => {
   return request.post(`/sysroles/list`,{})
}

// 角色切换
export const changeRoleIdMenus = ({roleId})=>{
   return request.post(`/sysroles/roles/change?roleId=${roleId}`,{})
}

export const selectRoleMenus = ()=>{}
export const saveRoleMenus = ()=>{}
